package com.esun.cheetah.view.setting.listener;

import org.jivesoftware.smack.ConnectionListener;

import com.esun.cheetah.view.setting.XmppManager;

/**
 * 监听push 的连接状态
 * com.esun.cheetah.view.setting.listener.PersistentConnectionListener
 * 
 * @author 任付江; create at 2012-5-7 上午11:18:26
 */
public class PersistentConnectionListener implements ConnectionListener {
	private final XmppManager xmppManager;

	public PersistentConnectionListener(XmppManager xmppManager) {
		this.xmppManager = xmppManager;
	}

	@Override
	public void connectionClosed() {
	}

	@Override
	public void connectionClosedOnError(Exception e) {
		if (xmppManager.getConnection() != null
				&& xmppManager.getConnection().isConnected()) {
			xmppManager.getConnection().disconnect();
		}
		xmppManager.startReconnectionThread();
	}

	@Override
	public void reconnectingIn(int seconds) {

	}

	@Override
	public void reconnectionFailed(Exception e) {
	}

	@Override
	public void reconnectionSuccessful() {
	}

}
